<template>
    <div class="tree-view">
      <h1>代码目录页</h1>
      <div class="params">
        <h2>当前路由参数：</h2>
        <p>branch: {{ route.params.branch }}</p>
        <p>dir: {{ route.params.dir }}</p>
      </div>
      <div>
        <p><RouterLink to="/tree/feat/main/docker">docker dir</RouterLink></p>
        <p><RouterLink to="/tree/feat/main/conf">conf dir</RouterLink></p>
        <p><RouterLink to="/tree/feat">单个单词路由</RouterLink></p>
        <p><button @click="testRoute">测试路由转义</button></p>
      </div>

      <div class="raw">
        <h2>完整路由信息：</h2>
        <pre>{{ route }}</pre>
      </div>
    </div>
  </template>

  <script setup>
  import { useRoute, useRouter } from 'vue-router'

  const route = useRoute()
  const router = useRouter()
  const testRoute = () => {
    // router.replace({
    //   name: 'tree-main',
    //   params: {
    //     branch: 'feat/nie/latest'
    //   }
    // });
    router.replace({path: '/tree/feat/nie/latest'})
  }
  </script>

  <style scoped>
  .tree-view {
    padding: 20px;
  }
  .params {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
  .raw {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 4px;
  }
  pre {
    white-space: pre-wrap;
  }
  </style>